package ai.people.netmon.framework.model.response;

import ai.people.netmon.framework.exception.enums.CommonEnum;
import ai.people.netmon.framework.exception.enums.ExceptionEnum;
import ai.people.netmon.framework.exception.type.CustomizeRuntimeException;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author: Xing.Wei
 * @time: 2020-09-02 10:50
 */
@Data
@ToString
@NoArgsConstructor
public class Result2<T> {

    /**
     * 成功
     */
    Boolean status = CommonEnum.SUCCESS.getStatus();
    /**
     * 状态码
     */
    Integer code = CommonEnum.SUCCESS.getCode();

    /**
     * 提示信息
     */
    String msg;

    /**
     * 数据
     */
    private T data;

    public Result2(Object data) {
        this.data = (T) data;
    }

    public Result2(ExceptionEnum exceptionEnum) {
        this.code = exceptionEnum.getCode();
        this.msg = exceptionEnum.getMessage();
        this.status = exceptionEnum.getStatus();
    }

    public Result2(CustomizeRuntimeException exception) {
        this.code = exception.getCode();
        this.msg = exception.getMessage();
        this.status = false;
    }

    public Result2(int code, String msg, boolean status) {
        this.code = code;
        this.msg = msg;
        this.status = status;
    }


}
